<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Hello, World</title>
		<script type="text/javascript"
			src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=mGf35O9tTAbouWXarLNETweA9rDH9v8q"> </script>
	</head>

	<body>
		<div id="container">
			<button onclick="getGPS()">获得坐标</button>
		</div>
		<script type="text/javascript">
			function getGPS() {
				var geolocation = new BMapGL.Geolocation();
				geolocation.getCurrentPosition(function(r) {
					if (this.getStatus() == BMAP_STATUS_SUCCESS) {
						alert('您的位置：' + r.point.lng + ',' + r.point.lat);
					} else {
						alert('failed' + this.getStatus());
					}
				});
			}
		</script>
	</body>
</html>
